
from django.db.models import CharField,IntegerField,ForeignKey,DO_NOTHING,TextField,DateField,DateTimeField,BooleanField,PROTECT
from apps.vadmin.op_drf.models import CoreModel


class AssetRecords(CoreModel):
    asset = ForeignKey(to="assets.Assets",null=True,db_constraint=False,on_delete=PROTECT,verbose_name="借出资产Id")
    assigned_to_id = IntegerField(null=True,verbose_name="借用到目标的id")
    assigned_to_name = CharField(max_length=256,null=True,verbose_name="借用到目标名称")
    assigned_type = CharField(max_length=32,null=True,verbose_name="借用类型") # asset/user/location,可以借给人，可以借给资产，可以借给位置
    checkout_date = DateField(null=True,verbose_name="借出日期")
    checkin_date = DateField(null=True,verbose_name="归还日期")
    expected_checkin_date = DateField(null=True,verbose_name="预计归还日期")
    checkin_datetime = DateTimeField(null=True,verbose_name="实际归还时间")
    is_checkin = BooleanField(null=True,default=0,verbose_name="是否归还")
    checkout_notes = TextField(null=True,verbose_name="借出备注")
    checkin_notes = TextField(null=True,verbose_name="归还备注")


    class Meta:
        verbose_name = '资产借用记录表'
        verbose_name_plural = verbose_name
        ordering = ['-id']  # 按id降序
